<template>
  <div>
    <el-dialog
        :modal="true"
        :modal-append-to-body="true"
        :title="tittle"
        v-model="isShow"
        :width="width"
        :height="height"
        :close-on-click-modal="false"
        :show-close="true"
        :close-on-press-escape="true"
        center>
      <el-form :model="form" enctype="multipart/form-data">
        <el-form-item label="姓名" :label-width="formLabelWidth" prop="name" >
          <el-input v-model="form.name"  placeholder="请输入送水工姓名" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="底薪" :label-width="formLabelWidth" prop="base_salary">
          <el-input v-model="form.base_salary"  placeholder="请输入送水工底薪" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="提成" :label-width="formLabelWidth" prop="commission">
          <el-input v-model="form.commission" placeholder="请输入送水工提成" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>

      <div >
        <el-button @click="cancel()" class="dialog-footer">取 消</el-button>
        <el-button type="primary" @click="submit()" class="dialog-footer">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import axios from "axios";

export default {
  inject:['reload'],
  props: {
    switchStyle: {
      type: Boolean,
      default: true
    },
    tittle: {
      type: String,
      default: '新增送水工'
    },
    width: {
      type: String,
      default: "30%"
    },
    height: {
      type: String,
      default: "1000px"
    },
  },
  data(){
    return {
      image_url: '',
      fileList:[],
      isShow:false,
      form: {
        name: '',
        base_salary:'',
        commission: '',
      },
      formLabelWidth: '60px'
    }
  },
  methods: {

    init() {
      var that = this;
      that.isShow = true;
    },
    submit() {
      var that = this;
      axios.post('/worker/add', this.form/*{
/!*        name: this.form.name,
        base_salary: this.form.base_salary,
        commission:this.form.commission,
        picture: this.form.picture*!/
      }*/)
          .then(function (response) {
            that.isShow = false;
            that.$parent.fresh();
            console.log(response);
          })
          .catch(function (error) {
            console.log(error);
          });

      axios.post
    },

    cancel() {
      this.isShow = false;
    },
  }
  }

</script>
<style scoped>
.dialog-footer{
  margin-right: 50px;
  margin-left: 70px;
}
</style>
